package de.gwtprime.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.client.rpc.IsSerializable;


public class Stock implements Serializable, IsSerializable{

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5127206611129108672L;

	
	
	private String symbol;
	
	private String displayName;
	
	private List<Day> days = new ArrayList<Day>();
	
	private TradeResult tradeResult;
	
	public Stock(){
		
	}


	public String getSymbol() {
		return symbol;
	}



	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}



	public String getDisplayName() {
		return displayName;
	}



	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}



	public List<Day> getDays() {
		return days;
	}



	public void setDays(List<Day> days) {
		this.days = days;
	}


	public TradeResult getTradeResult() {
		return tradeResult;
	}
	
	
	/**
	 * Get the performance of this index from the first until the last day.
	 */
	public double getIndexPerformance(){
		return (getLastDay().getClosingPrice()/getFirstDay().getClosingPrice()-1)*100;
	}


	public void setTradeResult(TradeResult tradeResult) {
		this.tradeResult = tradeResult;
	}
	
	
	/**
	 * Get the first day for this stock.
	 */
	public Day getFirstDay(){
		return days.get(0);
	}
	
	
	/**
	 * Get the last day for this stock.
	 */
	public Day getLastDay(){
		return days.get(days.size()-1);
	}


}
